<template>
    <div class="box">
        <el-table :data="tableData" style="width: 100%" @row-dblclick="dbrowclick" @cell-dblclick="celldbclick">
            <el-table-column v-for="(item, index) in tablecol" :key="index" :label="item.label" :prop="item.key">
                <template slot-scope="scope">
                    <div>
                        <el-input v-show="scope.row.show" v-model="scope.row[item.key]" placeholder="请输入"></el-input>
                        <span  v-show="!scope.row.show" >{{ scope.row[item.key] }}</span>
                    </div>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
export default {
    data() {
        return {
            select:1,
            tablecol: [
                { label: 'id', key: 'id' },
                { label: '姓名', key: 'name' },
                { label: '地址', key: 'adder' },
                { label: '成绩', key: 'score' },
                { label: '推送', key: 'comment' },
            ],
            tableData: [
                { id: 1, name: 'ce', adder: '12342134', score: 56, comment: 'asgas',show:false},
                { id: 2, name: 'ces', adder: '123214', score: 45, comment: 'qwrweqer',show:false},
                { id: 3, name: 'ceshiasf', adder: '23523432', score: 78, comment: 'werqwrq',show:false},
                { id: 4, name: 'ceasfdsi', adder: '512342343', score: 67, comment: 'wrqwer',show:false},
                { id: 5, name: 'ceshwreewi', adder: '1532423', score: 46, comment: 'wqrqwerqwt',show:false},
                { id: 6, name: 'asfasdf', adder: '252345234523', score: 78, comment: 'qwewerqw',show:false},
                { id: 7, name: 'safsd', adder: '23452345235', score: 74, comment: 'asdfsa',show:false},
                { id: 8, name: 'asdfasd', adder: '25632452523', score: 83, comment: 'afasfasdf',show:false},
                { id: 9, name: 'asfd', adder: '23564235356423', score: 84, comment: 'fasfasdga',show:false},
                { id: 10, name: 'assdadf', adder: '7456325634643', score: 94, comment: 'asfasdfsad',show:false}
            ]
        }
    },
    mounted() {
    },
    methods: {
        dbrowclick(row, column, event) {
            console.log(event, "行双击");
            // row.show=true
            this.tableData.map(item=>{
                if(item.id==row.id){
                    item.show=true
                }else{
                    item.show=false
                }
            })
        },
        celldbclick(row, column, cell, event) {
            console.log(row, column, cell, event, "单元格双击");
        },
    }
}
</script>
<style lang="scss" scoped></style>